﻿namespace KeRui.DAL
{
    using KeRui.DBUtility;
    using KeRui.Model;
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class SysCity
    {
        public DataSet GetList(string Province, string City, string District, int Type)
        {
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Province", SqlDbType.NVarChar, 50), new SqlParameter("@City", SqlDbType.NVarChar, 50), new SqlParameter("@District", SqlDbType.NVarChar, 50), new SqlParameter("@Type", SqlDbType.Int, 4) };
            parameters[0].Value = Province;
            parameters[1].Value = City;
            parameters[2].Value = District;
            parameters[3].Value = Type;
            return DbHelperSQL.RunProcedure("SysCity_GetList", parameters, "ds");
        }

        public KeRui.Model.SysCity GetModel(string Province, string City, string District)
        {
            KeRui.Model.SysCity city = new KeRui.Model.SysCity();
            DataSet set = this.GetList(Province, City, District, 4);
            if (set.Tables[0].Rows.Count > 0)
            {
                city.Province = set.Tables[0].Rows[0]["Province"].ToString();
                city.City = set.Tables[0].Rows[0]["City"].ToString();
                city.District = set.Tables[0].Rows[0]["District"].ToString();
                return city;
            }
            return null;
        }
    }
}

